<template lang="html">
  <div>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="医院名称" prop="name">
        <span v-show='!isMod'>南环街道社区服务中心</span>
        <el-input v-model="ruleForm.name" v-show='isMod'></el-input>
      </el-form-item>
      <el-form-item label="区域选择" prop="region">
        <span v-show='!isMod'>南环街道</span>
        <el-select v-model="ruleForm.region" placeholder="请选择活动区域" v-show='isMod'>
          <el-option label="南环街道社区卫生服务中心" value="shanghai"></el-option>
          <el-option label="城站路下属服务中心" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="医院商标" prop="name">
        <span v-show='!isMod'>
          <i class="icon iconfont icon-nanhuanlogo-copy"></i>
        </span>
        <el-input v-model="ruleForm.name" v-show='isMod'></el-input>
      </el-form-item>
      <el-form-item label="医院简介" >
        <el-input type="textarea" v-model="ruleForm.desc"></el-input>
      </el-form-item>
      <el-form-item label="电话" prop="name">
        <span v-show='!isMod'>0772-356986</span>
        <el-input v-model="ruleForm.name" v-show='isMod'></el-input>
      </el-form-item>
      <el-form-item label="网址" prop="name">
        <span v-show='!isMod'>www.52carlife.com</span>
        <el-input v-model="ruleForm.name" v-show='isMod'></el-input>
      </el-form-item>
      <el-form-item label="地址" prop="name">
        <span v-show='!isMod'>柳州市南环街道天马216号-9</span>
        <el-input v-model="ruleForm.name" v-show='isMod'></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')" v-show='!isMod'>立即修改</el-button>
        <el-button type="success" @click="submitForm('ruleForm')" v-show='isMod'>立即保存</el-button>
        <el-button @click="resetForm('ruleForm')"  v-show='isMod'>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        isMod:false,
        ruleForm: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        rules: {
          name: [
            { required: true, message: '请输入', trigger: 'blur' },
            { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          ],
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.isMod = true;
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style lang="less" scoped>
@fontColor:#fff9dd;
@backColor:#009983;
@primaryColor:#a8d182;
.iconfont{
  font-size: 50px;
  color: @backColor;
}
</style>
